package com.ruoyi.project.emr.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.emr.domain.EmrDrug;
import com.ruoyi.project.emr.service.IEmrDrugService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 药品项目Controller
 *
 * @author gzu
 * @date 2023-07-22
 */
@RestController
@RequestMapping("/emr/drug")
public class EmrDrugController extends BaseController
{
    @Autowired
    private IEmrDrugService emrDrugService;

    /**
     * 查询药品项目列表
     */
    @GetMapping("/list")
    public TableDataInfo list(EmrDrug emrDrug)
    {
        startPage();
        List<EmrDrug> list = emrDrugService.selectEmrDrugList(emrDrug);
        return getDataTable(list);
    }

    /**
     * 获取药品项目详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(emrDrugService.selectEmrDrugById(id));
    }

    /**
     * 新增药品信息
     */
    @PostMapping
    public AjaxResult add(@RequestBody EmrDrug emrDrug) {
        return toAjax(emrDrugService.insertEmrDrug(emrDrug));
    }

    /**
     * 修改药品项目
     */
    @PutMapping
    public AjaxResult edit(@RequestBody EmrDrug emrDrug)
    {
        return toAjax(emrDrugService.updateEmrDrug(emrDrug));
    }

    /**
     * 删除药品项目
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(emrDrugService.deleteEmrDrugByIds(ids));
    }
}
